/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.curso.java.VO;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.ManyToAny;


@Entity
@Table(name = "curso")
public class CursoVO  implements Serializable, IVO { 
    
    	private static final long serialVersionUID = -4969328588154523299L;

	@Id
	@GeneratedValue
	private Integer codigo;

	@Column(unique = true)
	private String descricao;
        
    @Column()
	private double valor;
               
	public Integer getCodigo() {
		return codigo;
	}

	public void setCodigo(Integer codigo) {
		this.codigo = codigo;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

        public double getValor() {
            return valor;
        }

        public void setValor(double valor) {
            this.valor = valor;
        }
                         
    	@ManyToMany(cascade = CascadeType.ALL)
        @LazyCollection(LazyCollectionOption.FALSE)
        //@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    	@JoinTable(name = "disciplinasdocurso", joinColumns = { @JoinColumn(name = "codigo_curso", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "codigo_disciplina", nullable = false, updatable = false) })
    	private List<DisciplinaVO> disciplinas;

    	public List<DisciplinaVO> getDisciplinas() {
    		return disciplinas;
    		    		
    	}

    	public void setDisciplinas(List<DisciplinaVO> disciplinas) {
    		this.disciplinas = disciplinas;
    	}
        
	@Override
	public String toString() {
		return "Codigo= " + codigo + ",  Nome= " + descricao ;
	}
}